local gongzhi = fk.CreateSkill{
    name = "jin_heg__gongzhi",
}

Fk:loadTranslationTable{
    ["jin_heg__gongzhi"] = "共执",
    [":jin_heg__gongzhi"] = "你可以跳过摸牌阶段，然后令与你势力相同的角色轮流摸一张牌，直到以此法共计摸四张牌。",

    ["$jin_heg__gongzhi1"] = "既以食晋禄，不敢窥神器。",
    ["$jin_heg__gongzhi2"] = "杨骏已死，公赏诸君，以悦众心。",
}

local H = require "packages.ol_hegemony.util"

gongzhi:addEffect(fk.EventPhaseChanging,{
    anim_type = "drawcard",
    can_trigger = function(self, event, target, player, data)
        return player:hasSkill(gongzhi.name) and player == target and data.phase == Player.Draw
      end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        data.skipped = true
        local players = room:getAlivePlayers()
        local x = 0
        while x < 4 do
          for _, p in ipairs(players) do
            if H.compareKingdomWith(player, p) and not p.dead then
              p:drawCards(1, gongzhi.name)
              x = x + 1
              if x >= 4 then
                break
              end
            end
          end
          if not table.find(players, function (p) return H.compareKingdomWith(player, p) and not p.dead end) then
            break
          end
        end
      end,
})

return gongzhi